package com.kiln.juxingqs.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.kiln.juxingqs.ui.MainActivity

class MeBroadcast : BroadcastReceiver() {

    companion object {
        const val MAIN_SWITCH_TAB = "zmlywp.main.switch"
    }

    override fun onReceive(context: Context?, intent: Intent?) {
        intent?.action.let {
            when (it) {
                MAIN_SWITCH_TAB -> {
                    if (context is MainActivity) {
                        intent?.getIntExtra("tabIndex", -1)?.let {
                            context.switchTab(it)
                        }
                    }
                }
            }
        }
    }
}